<!DOCTYPE html>
<html lang="zh">
	{include file="public1/_header" /}
	<body style="background: #fff;">
		<div class="layui-fluid">
			<div class="layui-row">
				<form class="layui-form" action="">
				<div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
					<div style="padding: 4px;">
						<fieldset class="layui-elem-field">
							<legend>绑定班牌</legend>
							<div class="layui-field-box">
								<table class="layui-table table-form">
									<colgroup>
										<col width="100">
										<col>
									</colgroup>
									<tbody>
										
										<tr>
											<th>注册码</th>
											<td>
												<input lay-reqText="注册码" readonly="readonly" type="text"  name="key" required lay-verify="required" autocomplete="off"
												 class="layui-input" value="{$key}">
											</td>
										</tr>
										<tr>
											<th>设备名称</th>
											<td>
												<input lay-reqText="设备名称" type="text" name="device" required lay-verify="required" autocomplete="off"
												 class="layui-input" value="{$device}">
											</td>
										</tr>
										<tr>
											<th>所属班级</th>
											<td>
												{if condition="isset($classInfo['id']) lt 1"}
													<input id="class_info" readonly lay-reqText="所属班级" type="text" name="class_info"  autocomplete="off"
													class="layui-input" value="{$classInfo['name']|default=''}">
												{else/}
													<input readonly lay-reqText="所属班级" type="text" name="class_info"  autocomplete="off"
												class="layui-input" value="{$classInfo['name']|default=''}">
												{/if}
												
											 <input id="class_id" readonly lay-reqText="所属班级" type="hidden" name="class_id"  autocomplete="off"
											 class="layui-input" value="{$classInfo['id']|default=''}">
											</td>
										</tr>
									</tbody>
								</table>
							</div>
						</fieldset>
					</div>
				</div>
				<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
					<div style="padding: 4px;">
						<fieldset class="layui-elem-field">
							<legend>其他设置</legend>
							<div class="layui-field-box">
								<table class="layui-table table-form">
									<colgroup>
										<col width="100">
										<col>
									</colgroup>
									<tbody>
										<tr>
											<th>屏保</th>
											<td>
												<input id="screen" type="text" name="screen_title" autocomplete="off"
												 class="layui-input" readonly  value="{if condition='$screen_type eq 1'}文字模式:{else/}图片模式:{/if}{$title}">
												 <input id="screen_id" type="hidden" name="screen_saver_id" autocomplete="off"
												  class="layui-input" readonly  value="{$screen_saver_id}">
											</td>
										</tr>
										<tr>
											<th>开关机</th>
											<td>
												<input id="switch" type="text" name="switch_title" autocomplete="off"
												 class="layui-input" value="{$switch['title']|default=''}" readonly>
												<input id="switch_id" type="hidden" name="switch_id"  autocomplete="off"
												 class="layui-input" value="{$switch['id']|default=''}" readonly>
											</td>
										</tr>
									</tbody>
								</table>
							</div>
						</fieldset>
					</div>
				</div>
				<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
					<div style="padding: 4px;">
						<fieldset class="layui-elem-field">
							<legend>模板设置</legend>
							<div class="layui-field-box">
								<table class="layui-table table-form">
									<colgroup>
										<col width="100">
										<col>
									</colgroup>
									<tbody>
										<tr>
											<th>横版</th>
											<td>
												<input id="horizontal" type="text" name="horizontal_title" autocomplete="off"
												 class="layui-input" value="{$horizontal['title']|default=''}" readonly>
												<input id="horizontal_id" type="hidden" name="horizontal_id" autocomplete="off"
												 class="layui-input" value="{$horizontal['id']|default=''}" readonly>
											</td>
										</tr>
										<tr>
											<th>竖版</th>
											<td>
												<input id="vertical" type="text" name="vertical_title" autocomplete="off"
												 class="layui-input" value="{$vertical['title']|default=''}" readonly>
												<input id="vertical_id" type="hidden" name="vertical_id" autocomplete="off"
												 class="layui-input" value="{$vertical['id']|default=''}" readonly>
											</td>
										</tr>
									</tbody>
								</table>
							</div>
						</fieldset>
					</div>
				</div>
				<div style="text-align: center;" class="layui-layout-admin">
					<input type="hidden" name="device_id" value="{$device_id}" />
					<button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
					<button type="button" id="close"  class="layui-btn layui-btn-primary">放弃</button>
				</div>
				</form>
			</div>
		</div>
	</body>
	<script type="text/javascript">
		$(function(){
			var url = "__STATIC__/admin/"
			layui.use(['form'], function() {
				var form = layui.form;
				var $ = layui.jquery;
				$("#class_info").click(function(){
					parent.layer.open({
						title: "设备班级信息",
						type: 2,
						area: ['1200px', '750px'],
						content: "{:url('class_info')}"
					});
				})
				$("#horizontal").click(function(){
					parent.layer.open({
						title: "设置横版模板",
						type: 2,
						area: ['1200px', '750px'],
						content: "{:url('temp_h_all')}"
					});
				})
				$("#vertical").click(function(){
					parent.layer.open({
						title: "设置竖版模板",
						type: 2,
						area: ['1200px', '750px'],
						content: "{:url('temp_v_all')}"
					});
				})
				$("#switch").click(function(){
					parent.layer.open({
						title: "设置开关机",
						type: 2,
						area: ['1200px', '750px'],
						content: "{:url('switch_all')}"
					});
				})
				$("#screen").click(function(){
					parent.layer.open({
						title: "设置屏保",
						type: 2,
						area: ['1200px', '750px'],
						content: "{:url('screen_saver_all')}"
					});
				})
				
				
				//监听提交
				form.on('submit(formDemo)', function(obj) {
					var index = parent.layer.getFrameIndex(window.name);
					var lfc = top.layerFrameConfig;
					var info = lfc.iframeB.info;
					$.post("{:url('seting')}", obj.field, function(res) {
						if (res.status == 1) {
							layer.msg('添加成功', {
								icon: 1,
								time: 300
							}, function() {
								parent.layer.close(index); //再执行关闭
								info.reload()
							});
				
						} else {
							layer.msg(res.message)
						}
					})
					return false;
				});
				
				
				$("#close").click(function(){
					var index = parent.layer.getFrameIndex(window.name);
					parent.layer.close(index);
				})
			})
		})
	</script>
</html>
